<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<body>
<div class="pull-left">
    <div class="form-group form-inline">
        总共${pageInfo.pages} 页，共${pageInfo.total} 条数据，跳转到
        <input type="text" style="width: 10%" id="Num">页
        <button type="submit" id="GO" style="width: 10%"><a href="javascript:goPage(getPageNum())">GO</a></button>
        ,每页
        <select id="paginate">
            <c:forEach begin="1" end="${pageInfo.total}" step="1" var="s">
            <option value ="${s}"<c:if test="${pageInfo.size eq s}">selected</c:if>>${s}</option>
            </c:forEach>
        </select>
        条数据
    </div>
</div>
<script>
    $("#paginate").change(function(){

        var size = $("#paginate").val();

        $("#pageSize").val(size);
        $("#pageForm").submit();
    })
</script>
<div class="box-tools pull-right">
    <ul class="pagination" style="margin: 0px;">
        <li >
            <a href="javascript:goPage(1)" aria-label="Previous">首页</a>
        </li>
        <li><a href="javascript:goPage(${pageInfo.prePage})">上一页</a></li>

        <c:forEach begin="1" end="${pageInfo.pages}" var="i">
            <li class="paginate_button ${pageInfo.pageNum==i ? 'active':''}"><a href="javascript:goPage(${i})">${i}</a></li>
        </c:forEach>

        <li><a href="javascript:goPage(${pageInfo.nextPage})">下一页</a></li>
        <li>
            <a href="javascript:goPage(${pageInfo.pages})" aria-label="Next">尾页</a>
        </li>
    </ul>
</div>
<%--${param} 中的param是el提供的内置对象，用户获取请求参数值。--%>
<%--${param.pageUrl} 相当于request.getAttribute("pageUrl");--%>

<form id="pageForm" action="${param.pageUrl}" method="post">
    <input type="hidden" name="pageNum" id="pageNum">  <!-- 修改请求参数 -->
    <input type="hidden" name="pageSize" id="pageSize">
</form>
<script>
    // 参数：当前页
    function goPage(pageNum) {
        document.getElementById("pageNum").value = pageNum;
        document.getElementById("pageForm").submit()
    }
    //拿文本框内的值
    function getPageNum(){
        let num = $("#Num").val();
        return num;
    }
</script>
</body>
</html>
